package com.uzai.console.service.feign.impl;

import com.uzai.common.result.ResponseCode;
import com.uzai.console.common.UzaiRespVo;
import com.uzai.console.dto.feign.uzaichat.UpdateUzaichatNotifyDto;
import com.uzai.console.service.feign.UzaichatFeignService;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * @Auther: liuqi
 * @Date: 2021/11/24 16:24
 * @Description:
 */
@Component
public class UzaichatFeignFallbackFactory implements FallbackFactory<UzaichatFeignService> {

    private static Logger logger = LoggerFactory.getLogger(UzaichatFeignFallbackFactory.class);

    @Override
    public UzaichatFeignService create(Throwable throwable) {

        logger.error("--会员调用微服务出错，err:={}", throwable);

        return new UzaichatFeignService() {
            @Override
            public UzaiRespVo<String> updateNotify(UpdateUzaichatNotifyDto updateUzaichatNotifyDto) {
                UzaiRespVo<String> uzaiRespVo= new UzaiRespVo<>();
                uzaiRespVo.setData(null);
                uzaiRespVo.setCode(ResponseCode.ERROR);
                uzaiRespVo.setTime(System.currentTimeMillis());
                uzaiRespVo.setMsg("调用失败");
                return uzaiRespVo;
            }
        };
    }

}
